const month = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
function get20Year() {
    let currentYear = parseInt(new Date().getFullYear());
    let year = currentYear;
    let yearsArr = [];
    for (let i = currentYear; i <= currentYear + 20; i++) {
        yearsArr.push(year++);
    }
    return yearsArr;
}
function getMonthDay(year, month) {
    let flag = year % 400 == 0 || (year % 4 == 0 && year % 100 != 0),
        array = null;
    switch (month) {
        case 1:
        case 3:
        case 5:
        case 7:
        case 8:
        case 10:
        case 12:
            array = getLoopArray(1, 31);
            break;
        case 4:
        case 6:
        case 9:
        case 11:
            array = getLoopArray(1, 30)
            break;
        case 2:
            array = flag ? getLoopArray(1, 29) : getLoopArray(1, 28)
            break;
    }
    return array;
}
function getLoopArray(start, end) {
    var start = start || 0;
    var end = end || 1;
    var array = [];
    for (var i = start; i <= end; i++) {
        array.push(withData(i));
    }
    return array;
}

function withData(param) {
    return param < 10 ? '0' + param : '' + param;
}

function getDatePicker(){
    let pickArr = [[] , [] , []];
    pickArr[0] = get20Year();
    pickArr[1] = month;
    pickArr[2] = getMonthDay(pickArr[0][0] , 1);
    return pickArr;
}

module.exports = {
    getDatePicker,
    getMonthDay
}